home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / language / embedded / develop / symcoff.arc / PLDFCN.H < prev    next >
Text File  |  1988-11-02  |  3KB  |  107 lines

  1. /* Copyright 1985 by Motorola Inc. */
  2. /* @(#)pldfcn.h 2.1 */
  3. /*
  4.  *      The following two declarations appear in the IH versions of
  5.  *      "stdio.h" but do not appear in the normal 1.2 versions.
  6.  */
  7.  
  8. long ftell();
  9. char *fgets();
  10.  
  11.  
  12. #ifndef LDFILE
  13. struct  ldfile {
  14.         int     _fnum_;         /* so each instance of an LDFILE is unique */
  15.         FILE    *ioptr;         /* system I/O pointer value */
  16.         long    offset;         /* absolute offset to the start of the file */
  17.         FILHDR  header;         /* the file header of the opened file */
  18.         unsigned short  type;   /* indicator of the type of the file */
  19. };
  20.  
  21.  
  22. /*
  23.         provide a structure "type" definition, and the associated
  24.         "attributes"
  25. */
  26.  
  27. #define LDFILE          struct ldfile
  28. #define IOPTR(x)        x->ioptr
  29. #define OFFSET(x)       x->offset
  30. #define TYPE(x)         x->type
  31. #define HEADER(x)       x->header
  32. #define LDFSZ           sizeof(LDFILE)
  33.  
  34. /*
  35.         define various values of TYPE(ldptr)
  36. */
  37.  
  38. #define LDTYPE  B16MAGIC    /* defined in terms of the filehdr.h include file */
  39. #define ARTYPE  0177545
  40.  
  41. /*
  42.         define symbolic positioning information for FSEEK (and fseek)
  43. */
  44.  
  45. #define BEGINNING       0
  46. #define CURRENT         1
  47. #define END             2
  48.  
  49. /*
  50.         define a structure "type" for an archive header
  51. */
  52.  
  53. typedef struct { char ar_name[14];
  54.                  long ar_date;
  55.                  short ar_uid;
  56.                  short ar_gid;
  57.                  long ar_mode;
  58.                  long ar_size; } archdr;
  59.  
  60. #define ARCHDR  archdr
  61. #define ARCHSZ  sizeof(ARCHDR)
  62.  
  63.  
  64. /*
  65.         define some useful symbolic constants
  66. */
  67.  
  68. #define SYMTBL  0       /* section nnumber and/or section name of the Symbol Table */
  69.  
  70. #define SUCCESS  1
  71. #define CLOSED   1
  72. #define FAILURE  0
  73. #define NOCLOSE  0
  74. #define BADINDEX        -1L
  75.  
  76. #define OKFSEEK 0
  77.  
  78. /*
  79.         define macros to permit the direct use of LDFILE pointers with the
  80.         standard I/O library procedures
  81. */
  82.  
  83. extern long pldtbndex();
  84. extern char *pldgetnam();
  85. extern int  pldahread(), pldaclose(), pldclose(), pldfhread(),pldlseek();
  86. extern int  pldnlseek(), pldnrseek(), pldnshread(), pldnsseek(), pldohseek();
  87. extern int  pldrseek(), pldshread(), pldsseek(), pldtbread(), pldtbseek();
  88. extern LDFILE *pldallocptr(), *pldaopen(), *pldopen();
  89.  
  90. #define GETC(ldptr)     getc(IOPTR(ldptr))
  91. #define GETW(ldptr)     getw(IOPTR(ldptr))
  92. #define FEOF(ldptr)     feof(IOPTR(ldptr))
  93. #define FERROR(ldptr)   ferror(IOPTR(ldptr))
  94. #define FGETC(ldptr)    fgetc(IOPTR(ldptr))
  95. #define FGETS(s,n,ldptr)        fgets(s,n,IOPTR(ldptr))
  96. #define FILENO(ldptr)   fileno(IOPTR(ldptr))
  97. #define FREAD(p,s,n,ldptr)      fread(p,s,n,IOPTR(ldptr))
  98. #define FSEEK(ldptr,o,p)        fseek(IOPTR(ldptr),(p==BEGINNING)?(OFFSET(ldptr)+o):o,p)
  99. #define FTELL(ldptr)    ftell(IOPTR(ldptr))
  100. #define FWRITE(p,s,n,ldptr)       fwrite(p,s,n,IOPTR(ldptr))
  101. #define REWIND(ldptr)   rewind(IOPTR(ldptr))
  102. #define SETBUF(ldptr,b) setbuf(IOPTR(ldptr),b)
  103. #define UNGETC(c,ldptr)         ungetc(c,IOPTR(ldptr))
  104. #define STROFFSET(ldptr)        (HEADER(ldptr).f_symptr + HEADER(ldptr).f_nsyms * 18) /* 18 == SYMESZ */
  105. #endif
  106. /* Copyright 1985 by Motorola Inc. */
  107.